package gold.digger;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC1472 {
    public long startExecuteTime = System.currentTimeMillis();


    class BrowserHistory {

        String[] stack = new String[25];
        int length = 0;
        int limit = 0;

        public BrowserHistory(String homepage) {
            stack[length++] = homepage;
            limit = length;
        }

        public void visit(String url) {
            if (length == stack.length) {
                stack = Arrays.copyOf(stack, stack.length * 2);
            }
            stack[length++] = url;
            limit = length;
        }

        public String back(int steps) {
            length = Math.max(length - steps, 1);
            return stack[length - 1];
        }

        public String forward(int steps) {
            length = Math.min(length + steps, limit);
            return stack[length - 1];
        }
    }


    public void run() {
        BrowserHistory solution = new BrowserHistory("");
        List<Integer> list = new ArrayList<>();
        System.out.println(solution.toString());
    }

    public static void main(String[] args) throws Exception {
        LC1472 an = new LC1472();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
